﻿@using FwProject.PrePaymentInfo.Dto
@using X.PagedList
@model IPagedList<ReceiptInfoDto>
@{
    ViewBag.Title = "收款单";
}
@section styles{
    <link href="~/Theme/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Theme/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <style type="text/css">
        .input-group[class*=col-] {
            padding: 0 15px;
        }
    </style>
}
<div class="row wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>@ViewBag.Title</h5>
                <div class="ibox-tools">
                    @if (IsGranted(FwProject.Authorization.PermissionNames.Finance_Operation_AddPaid))
                    {
                        <button class="btn btn-primary btn-xs" onclick="top.window.openTab(1059,'添加收款单','@Url.Action("Create")');"><i class="fa fa-plus"></i>添加收款单</button>
                    }
                    else
                    {
                        <button type="button" class="btn btn-default btn-xs">无收款权限</button>
                    }
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li>
                            <a href="javascript:Print()">打印</a>
                        </li>
                        <li>
                            <a href="javascript:Export()">导出</a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="ibox-content">
                @*<div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a data-toggle="tab" href="#tab-1" aria-expanded="true"><i class="fa fa-file-text-o"></i> 未作废</a>
                        </li>
                        <li class="">
                            <a data-toggle="tab" href="#tab-2" aria-expanded="false"><i class="glyphicon glyphicon-paste"></i> 已作废</a>
                        </li>
                    </ul>*@
                @*<div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="panel-body">*@
                <div class="row m-b-sm m-t-sm">
                    <form class="form-horizontal" id="form" asp-controller="Receipt" asp-action="Index" data-ajax="true" data-ajax-update="#data_list" data-ajax-method="Get" data-ajax-mode="replace"   data-ajax-begin="AjaxBegin" data-ajax-success="AjaxSuccessCallback">
                        <input type="hidden" id="size" name="size" value="0" />
                        <div class="form-group">
                            <div class="col-md-2 col-lg-2">
                                <label class="control-label col-md-5 col-lg-4">单号：</label>
                                <div class="input-group">
                                    <input type="text" name="ReceiptInfoNumber" id="ReceiptInfoNumber" placeholder="请输入收款单号" class="input-sm form-control" autocomplete="off">
                                </div>
                            </div>
                            <div class="col-md-3 col-lg-2">
                                <label class="control-label col-md-5 col-lg-5">收款经办人：</label>
                                <div class="input-group">
                                    <input type="hidden" name="AgentPeoperUserId" id="AgentPeoperUserId" />
                                    <input type="text" id="dropdown-agentpeoperuserid" class="form-control" onblur="blurEmpty()">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="line-height:1.455;padding:6px 12px;">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index: 9999;"></ul>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-5 col-lg-5">
                                <label class="control-label col-md-3 col-lg-2">收款日期：</label>
                                <div class="col-md-3 col-lg-2">
                                    <select id="data_select_receipt" class="input-s form-control"></select>
                                </div>
                                <div class="input-daterange input-group" id="datepickerReceipt">
                                    <input type="text" name="ReceiptBeginTime" id="ReceiptBeginTime" placeholder="起始日期" class="input-sm form-control" autocomplete="off">
                                    <span class="input-group-addon">至</span>
                                    <input type="text" name="ReceiptEndTime" id="ReceiptEndTime" placeholder="结束日期" class="input-sm form-control" autocomplete="off" />
                                </div>
                            </div>
                            <div class="col-md-2 col-lg-2">
                                <label class="control-label col-md-5 col-lg-5">状态：</label>
                                <div class="input-group">
                                    <select class="form-control" name="ReceiptInfoStatus" id="ReceiptInfoStatus">
                                        <option value="" selected="selected">全部</option>
                                        <option value="0">未提交</option>
                                        <option value="1">已提交</option>
                                        <option value="2">已审核</option>
                                        <option value="3">退回</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-2 col-lg-2">
                                <label class="control-label col-md-5 col-lg-4">餐厅：</label>
                                <div class="input-group">
                                    <input type="text" name="RestaurantName" id="RestaurantName" placeholder="请输入餐厅名称" class="input-sm form-control" autocomplete="off">
                                </div>
                            </div>
                            <div class="col-md-3 col-lg-2">
                                <label class="control-label col-md-5 col-lg-5">缴款经办人：</label>
                                <div class="input-group">
                                    <input type="hidden" name="PaymentPerson" id="PaymentPerson" />
                                    <input type="text" id="dropdown-paymentperson" class="form-control" onblur="blurEmpty1()">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="line-height:1.455;padding:6px 12px;">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index: 9999;"></ul>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-5 col-lg-5">
                                <label class="control-label col-md-3 col-lg-2">缴款日期：</label>
                                <div class="col-md-3 col-lg-2">
                                    <select id="data_select_payment" class="input-s form-control"></select>
                                </div>
                                <div class="input-daterange input-group" id="datepickerPayment">
                                    <input type="text" name="PaymentBeginTime" id="PaymentBeginTime" placeholder="起始时间" class="input-sm form-control" autocomplete="off">
                                    <span class="input-group-addon">至</span>
                                    <input type="text" name="PaymentEndTime" id="PaymentEndTime" placeholder="结束时间" class="input-sm form-control" autocomplete="off" />
                                </div>
                            </div>
                            <div class="col-md-1">
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary"> 查询</button>
                                </span>
                            </div>
                        </div>

                    </form>
                </div>
                <div id="data_list">
                    @*@{Html.RenderPartial("IndexPartial", Model);}*@
                </div>

            </div>
        </div>
    </div>
</div>
<div id="modal_ajax" class="modal inmodal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
</div>
@section scripts{
    <script src="~/Theme/js/content.min.js?v=1.0.0"></script>
    <script src="~/Theme/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/Theme/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="~/Theme/js/plugins/suggest/bootstrap-suggest2014.js"></script>
    <script src="~/js/DateComm.js"></script>
    <script src="~/js/PrintUtil.js"></script>
    <script type="text/javascript">
        function Print() {
            printGirdObj({
                containerId: 'table_print',//包含表格容器のID
                title: '收款单',
                showRowNum: false,  //表格中rownumbers: true时为true
                showOrder: false,//是否显示序号，rownumbers: true时有效，默认false
                printInit: { //打印初始化设置参数
                    portrait: false //true纵向,false横向
                }
            });
        }
        function Export() {
            var ReceiptInfoNumber = $('#ReceiptInfoNumber').val();
            var AgentPeoperUserId = $('#AgentPeoperUserId').val();
            var ReceiptBeginTime = $('#ReceiptBeginTime').val();
            var ReceiptEndTime = $('#ReceiptEndTime').val();
            var ToVoid = $("#ToVoid").find("option:selected").val();
            var RestaurantName = $('#RestaurantName').val();
            var PaymentPerson = $('#PaymentPerson').val();
            var PaymentBeginTime = $('#PaymentBeginTime').val();
            var PaymentEndTime = $('#PaymentEndTime').val();
            window.location.href = "/Receipt/ExportExcel?ReceiptInfoNumber=" + ReceiptInfoNumber + "&AgentPeoperUserId=" + AgentPeoperUserId + "&ReceiptBeginTime=" + ReceiptBeginTime + "&ReceiptEndTime=" + ReceiptEndTime + "&ToVoid=" + ToVoid + "&RestaurantName=" + RestaurantName + "&PaymentPerson=" + PaymentPerson + "&PaymentBeginTime=" + PaymentBeginTime + "&PaymentEndTime=" + PaymentEndTime;
        }

        //layer.msg("test",{time:2000});
        $(document).ready(function () {
            $.getJSON("/Payment/GetAgentPeoperData").done(function (data) {
                CommonAjaxCallback(data, function () {
                    bindSuggest(data.result);
                    bindSuggest1(data.result);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取经办人失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            $('#modal_ajax').on('show.bs.modal', function (e) {
                $(this).addClass('loading');
                var $button = $(e.relatedTarget);
                var url = $button.data('url');
                if (!!url) {
                    url = url + ((url.indexOf("?") > -1) ? "&r=" : "?r=") + Math.random();
                    $(this).load(url, function () {
                        $.validator.unobtrusive.parse(this); //$("#form_model_create").validate();
                        $("input[name='Member.Birthday']").datepicker({ todayBtn: "linked", keyboardNavigation: !1, forceParse: !1, calendarWeeks: !0, autoclose: !0 });
                        $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
                        $(this).removeClass('loading');
                    });
                }
            });
            $('#modal_ajax').on('hidden.bs.modal', function (e) {
                $(this).empty();
            });

            $('#modal_del,#modal_password_reset').on('show.bs.modal', function (e) {
                var $button = $(e.relatedTarget);
                var url = $button.data('url');
                if (!!url)
                    url = url + ((url.indexOf("?") > -1) ? "&r=" : "?r=") + Math.random();
                $(this).find("form").attr("action", url);
            });
            $('#modal_del,#modal_password_reset').on('hidden.bs.modal', function (e) {
                $(this).find("form").attr("action", "");
            });

            //开始时间
            $('#ReceiptBeginTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true

            }).on('changeDate', function (e) {
                var startTime = e.date;
                $('#ReceiptEndTime').datepicker('setStartDate', startTime);
            });
            //结束时间：
            $('#ReceiptEndTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true

            }).on('changeDate', function (e) {
                var endTime = e.date;
                $('#ReceiptBeginTime').datepicker('setEndDate', endTime);
            });

            //开始时间
            $('#PaymentBeginTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true

            }).on('changeDate', function (e) {
                var startTime = e.date;
                $('#PaymentEndTime').datepicker('setStartDate', startTime);
            });
            //结束时间：
            $('#PaymentEndTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true

            }).on('changeDate', function (e) {
                var endTime = e.date;
                $('#PaymentBeginTime').datepicker('setEndDate', endTime);
            });

            $('#form').submit();
        });
        function bindSuggest(data) {
            if ($("#dropdown-agentpeoperuserid") != undefined) {
                $role = $("#dropdown-agentpeoperuserid").bsSuggest({
                    effectiveFields: ["name"],
                    effectiveFieldsAlias: { "name": "姓名" },
                    searchFields: ["name"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "name",
                    callfun: function () {
                        $("#AgentPeoperUserId").val("");
                    }
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#AgentPeoperUserId").val(data.id);
                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }
        function blurEmpty() {
            var cityObj = $("#dropdown-agentpeoperuserid");
            var DriverId = $("#AgentPeoperUserId");
            if (cityObj.val() == "") {
                DriverId.attr("value", "");
            }
        }
        function bindSuggest1(data) {
            if ($("#dropdown-paymentperson") != undefined) {
                $role = $("#dropdown-paymentperson").bsSuggest({
                    effectiveFields: ["name"],
                    effectiveFieldsAlias: { "name": "姓名" },
                    searchFields: ["name"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "name",
                    callfun: function () {
                        $("#PaymentPerson").val("");
                    }
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#PaymentPerson").val(data.id);
                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }
        function blurEmpty1() {
            var cityObj = $("#dropdown-paymentperson");
            var DriverId = $("#PaymentPerson");
            if (cityObj.val() == "") {
                DriverId.attr("value", "");
            }
        }
        function ReloadAjaxCallbackgoback(data, successInfo) {
            CommonAjaxCallback(data, function () {
                $('#modal_ajax').modal("hide");
                window.location.reload();
            }, successInfo);
        }

        new DateContUtil({//【下拉日期】
            selectId: "data_select_receipt",//下拉框のID
            startDate: 'ReceiptBeginTime',//开始日期(不填默认search_startDateBase)
            endDate: 'ReceiptEndTime',//结束日期(不填默认search_endDateBase)
            defaultValue: '4',//本月
            selectedFun: function () {//选中后触发の方法
                $(".form-horizontal").submit();
            }
        });

        new DateContUtil({//【下拉日期】
            selectId: "data_select_payment",//下拉框のID
            startDate: 'PaymentBeginTime',//开始日期(不填默认search_startDateBase)
            endDate: 'PaymentEndTime',//结束日期(不填默认search_endDateBase)
            defaultValue: '0',//本月
            selectedFun: function () {//选中后触发の方法
                $(".form-horizontal").submit();
            }
        });

        $("#data_list").on("change", "#pageSize", function () {
            layer.load();
            var size = $("option:selected", this).val();
            var pageurl = $("#pageurl").val();
            $("#data_list").load("/Receipt/Index?size=" + size + "&r=" + Math.random() + pageurl, function () {
                layer.closeAll();
                $("#size").val($("option:selected", this).val());
            });
        });
    </script>
}

